import React,{useState,useContext,memo} from 'react'
import '../index.less'
import FatherContext from '../FatherContext'
const SunZi = () => {
  const Context = useContext(FatherContext)
  const changeText = ()=>{
    Context.setText("我被孙子改了" + Math.random())
  }
  console.log("测试memo--孙子")
  return (
    <div>
      <h3>我是孙子级组件</h3>
      <div className="box">
        {Context.text}
        <button onClick={changeText}>点我改变文案</button>
      </div>
    </div>
  )
}
//子组件只需要使用导出的memo包裹即可
export default memo(SunZi)